<?php
	class Settings extends Model_Abstract{
		public function setConf($k, $v)
		{
			$sql = " SELECT id FROM `configs` WHERE k=? ";
			$result = $this->_connection->query($sql, array($k));
			if(count($result) <= 0){
				$sql = " INSERT INTO `configs` SET `v`=?, k=? ";
			}else{
				$sql = "UPDATE `configs` SET `v`=? WHERE k=?";
			}
			try
			{
				return $this->_connection->execute($sql, array($v, $k));
			}
			catch (Exception $e)
			{
				QLog::log(__CLASS__.' '.__METHOD__.' --- '.$e->getMessage(), QLog::ERR);
				throw new Model_Exception($e->getMessage(), $e->getCode());
			}
		}
		
		public function getConf()
		{
			$sql = "SELECT * FROM `configs` ";
			try{
				return $this->_connection->query($sql);
			}catch (Exception $e){
				QLog::log(__CLASS__.' '.__METHOD__.' --- '.$e->getMessage(), QLog::ERR);
				throw new Model_Exception($e->getMessage(), $e->getCode());
			}
		}
	}
?>